---
slug: /ci/integrations/tekton
---

# Tekton

Dagger provides a programmable container engine that can be invoked from Tekton to run a Dagger pipeline. This allows you to benefit from Dagger's caching, debugging, and visualization features, whilst still keeping all of your existing Tekton infrastructure.

## How it works

Tekton provides capabilities which allow you to run a Dagger pipeline as a Tekton Task without needing any external configuration. This integration uses the standard architecture for Tekton and adds a Dagger Engine sidecar which gives each Tekton PipelineRun its own Dagger Engine.

To trigger a pipeline run, you can use the Tekton CLI (`tkn`), or you can configure events in Tekton to run it automatically as desired.

## Prerequisites

- A running Kubernetes cluster [configured for use with Dagger](./kubernetes.mdx) and with a pre-configured `kubectl` profile
- Tekton and the Tekton CLI [installed](https://tekton.dev/docs/getting-started/) in the cluster

## Example

The following example builds a simple [Go application](https://github.com/kpenfound/greetings-api) using a Dagger Function. This project uses the Dagger Go SDK for CI.

Install the `git-clone` Task from Tekton Hub. This Task adds repository cloning capabilities to the Tekton Pipeline. Use the following command:

```shell
tkn hub install task git-clone
```

Define a new Tekton Pipeline as follows, in a file named `git-pipeline.yaml`:

```yaml title="git-pipeline.yaml" file=./snippets/tekton-git-pipeline.yaml
```

This Pipeline references two Tasks:

- The `git-clone` Task, to check out the Git repository for the project into a Tekton Workspace;
- A custom `dagger` Task, to run the Dagger pipeline for the project (defined below).

Define a new Tekton Task as follows, in a file named `dagger-task.yaml`:

```yaml title="dagger-task.yaml" file=./snippets/tekton-dagger-task.yaml template
```

This Tekton Task installs the Dagger CLI and calls a Dagger Function. This Task installs the dependencies needed to execute the Dagger pipeline for the project (which was checked out in the previous Tekton Pipeline) and then calls a Dagger Function to build the project.

In this Tekton Task, the Dagger Engine runs as a sidecar and shares a socket with the Task itself. The Task uses `dind` as its runtime in order to have Docker available.

Define a new Tekton PipelineRun as follows, in a file named `git-pipeline-run.yaml`:

```yaml title="git-pipeline-run.yaml" file=./snippets/tekton-git-pipeline-run.yaml
```

This PipelineRun corresponds to the Tekton Pipeline created previously. It executes the Tekton Pipeline with a given set of input parameters: the Git repository URL and an optional Dagger Cloud token.

To apply the configuration and run the Tekton Pipeline, use the following commands:

```shell
kubectl apply -f dagger-task.yaml
kubectl apply -f git-pipeline-yaml
kubectl create -f git-pipeline-run.yaml
```

To see the logs from the PipelineRun, obtain the PipelineRun name from the output and run `tkn pipelinerun logs clone-read-run-<id> -f`.

## Resources

If you have any questions about additional ways to use Tekton with Dagger, join our [Discord](https://discord.gg/dagger-io) and ask your questions in our [Kubernetes channel](https://discord.com/channels/707636530424053791/1122942037096927353).

## About Tekton

[Tekton](https://tekton.dev/) is a Kubernetes-based framework for creating, managing and running CI/CD pipelines.
